package edu.cmu.mism.dgjava.data.ui.composites.bond;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;

import edu.cmu.mism.dgjava.data.ui.composites.AbstractDataComposite;
import edu.cmu.mism.dgjava.utils.SWTUtils;
import edu.cmu.mism.dgjava.views.Messages;

public class LogNormalEuropeanComposite extends AbstractDataComposite{

	private static final String DEFAULT_STRIKE_PRICE = "100.00";
	private static final String DEFAULT_OPTION_LIFE = "1.00";
	private static final String DEFAULT_SHORT_RATE_VOLATILITY = "15.00%";
	private static final String DEFAULT_REVERSION_RATE = "6.00%";
	private static final String DEFAULT_TREE_STEPS = "10";

	private Group _priceModelGroup;
	
	private Label _strikePriceLbl;
	private Text _strikePriceTxt;

	private Label _optionLifeLbl;
	private Text _optionLifeTxt;

	private Label _shortRateVolatilityLbl;
	private Text _shortRateVolatilityTxt;

	private Label _reversionRateLbl;
	private Text _reversionRateTxt;

	private Label _treeStepsLbl;
	private Text _treeStepsTxt;

	@Override
	public void createControls(Composite parent) {
		
		Composite container = SWTUtils.createComposite(parent, 1, -1, 1);
		GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
		container.setLayoutData(gd);
		createPriceModelGroup(container);
		
	}

	private void createPriceModelGroup(Composite container) {

		GridData hGd = new GridData(GridData.FILL_HORIZONTAL);
		GridData labelGd = new GridData(GridData.HORIZONTAL_ALIGN_END);
		// strike price
		this._priceModelGroup = SWTUtils.createGroup(container,
				Messages.BondDataView_group_priceModel, 2, 2, -1,
				GridData.FILL_HORIZONTAL);
		this._strikePriceLbl = SWTUtils.createLabel(this._priceModelGroup,
				Messages.BondDataView_label_strikePrice, 1);
		this._strikePriceLbl.setLayoutData(labelGd);
		this._strikePriceTxt = SWTUtils.createTextBox(this._priceModelGroup,
				DEFAULT_STRIKE_PRICE); 
		hGd = new GridData(SWT.FILL, -1, true, false);
		this._strikePriceTxt.setLayoutData(hGd);
		this._strikePriceLbl.setLayoutData(hGd);

		// Option Life
		this._optionLifeLbl = SWTUtils.createLabel(this._priceModelGroup,
				Messages.BondDataView_label_optionLife, 1);
		this._optionLifeLbl.setLayoutData(labelGd);
		this._optionLifeTxt = SWTUtils.createTextBox(this._priceModelGroup,
				DEFAULT_OPTION_LIFE); 
		hGd = new GridData(SWT.FILL, -1, true, false);
		this._optionLifeTxt.setLayoutData(hGd);
		this._optionLifeLbl.setLayoutData(hGd);
		
		// Short rate volatility
		this._shortRateVolatilityLbl = SWTUtils.createLabel(this._priceModelGroup,
				Messages.BondDataView_label_shortRateVolatility, 1);
		this._shortRateVolatilityLbl.setLayoutData(labelGd);
		this._shortRateVolatilityTxt = SWTUtils.createTextBox(this._priceModelGroup,
				DEFAULT_SHORT_RATE_VOLATILITY); 
		hGd = new GridData(SWT.FILL, -1, true, false);
		this._shortRateVolatilityTxt.setLayoutData(hGd);
		this._shortRateVolatilityLbl.setLayoutData(hGd);
		
		// Reversion Rate
		this._reversionRateLbl = SWTUtils.createLabel(this._priceModelGroup,
				Messages.BondDataView_label_reversionRate, 1);
		this._reversionRateLbl.setLayoutData(labelGd);
		this._reversionRateTxt = SWTUtils.createTextBox(this._priceModelGroup,
				DEFAULT_REVERSION_RATE); 
		hGd = new GridData(SWT.FILL, -1, true, false);
		this._reversionRateTxt.setLayoutData(hGd);
		this._reversionRateLbl.setLayoutData(hGd);
		
		// Tree Steps
		this._treeStepsLbl = SWTUtils.createLabel(this._priceModelGroup,
				Messages.BondDataView_label_treeStep, 1);
		this._treeStepsLbl.setLayoutData(labelGd);
		this._treeStepsTxt = SWTUtils.createTextBox(this._priceModelGroup,
				DEFAULT_TREE_STEPS); 
		hGd = new GridData(SWT.FILL, -1, true, false);
		this._treeStepsTxt.setLayoutData(hGd);
		this._treeStepsLbl.setLayoutData(hGd);
		
		
	}

	@Override
	protected void validate() {
		// TODO Auto-generated method stub
		
	}


}
